package cn.tedu._01mvcboot01.controller;

import cn.tedu._01mvcboot01.pojo.dto.BMIdto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("api")
public class BMIController {
    @RequestMapping("/bmi")
    @ResponseBody
    public String bmi(BMIdto bmiDto) {
        Double height = bmiDto.getHeight();
        Double weight = bmiDto.getWeight();
        double v = weight / (height * height);
        //判断
        if (v<18.5){
            return "偏瘦";
        }
        if (v<24){
            return "正常";
        }
        if (v<27){
            return "微胖";
        }else {
            return "该减肥了";
        }
    }
}
